home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 18 code / Hierarchical Lists / Src / SpinCursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-16  |  1.3 KB  |  63 lines  |  [TEXT/KAHL]

  1. /*                                    SpinCursor.c                                */
  2. /*
  3.  * List In A List Sample
  4.  * SpinCursor.c
  5.  * Copyright © 1993-94 Apple Computer Inc.
  6.  * This is based on a sample in Think Reference 2.0.
  7.  */
  8. #include "ListInAList.h"
  9. #define ACUR    (**gACUR_Handle)
  10.  
  11. /*
  12.  * SetupAnimatedCursor
  13.  * Build the animated cursor handle array (in global gACUR_Handle)
  14.  */
  15. void
  16. SetupAnimatedCursor(
  17.         short                        acurResID
  18.     )
  19. {
  20.         short                    cursorID;
  21.         short                    i;
  22.  
  23.         gACUR_Handle = (ACUR_Handle) GetResource('acur', acurResID);
  24.         if (gACUR_Handle != NULL) {
  25.             DetachResource((Handle) gACUR_Handle);
  26.             for (i = 0; i < ACUR.nFrames; i++) {
  27.                 cursorID = ((unsigned long) ACUR.frame[i]) >> 16;
  28.                 ACUR.frame[i] = GetCursor(cursorID);
  29.                 if (ACUR.frame[i] == NULL)
  30.                     break;
  31.                 HNoPurge((Handle) ACUR.frame[i]);
  32.             }
  33.             ACUR.nFrames = i;
  34.             ACUR.nextFrame = 0;
  35.             if (i == 0) {
  36.                 DisposeHandle((Handle) gACUR_Handle);
  37.                 gACUR_Handle = NULL;
  38.             }
  39.         }
  40.         gACUR_NextAnimation = 0;
  41. }
  42.  
  43. /*
  44.  * SpinCursor
  45.  * This is called repeatedly to change the cursor animation.
  46.  */
  47. void
  48. SpinCursor(void)
  49. {
  50.         unsigned long                now;
  51.         
  52.         if (gACUR_Handle != NULL) {
  53.             now = TickCount();
  54.             if (now > gACUR_NextAnimation) {
  55.                 gACUR_NextAnimation = now + kAnimationInterval;
  56.                 if (ACUR.nextFrame >= ACUR.nFrames)
  57.                     ACUR.nextFrame = 0;
  58.                 SetCursor(*ACUR.frame[ACUR.nextFrame]);
  59.                 ++ACUR.nextFrame;
  60.             }
  61.         }
  62. }
  63.